<?php

$fd = fopen("access.txt", "r");

$data=array();
if ($fd) {
    while (!feof($fd)) {
        $buff = fgets($fd, 4096);
	$elt=explode ( " ", $buff);
        
	if (!isset($elt[6]) or !strstr($elt[6], ".php")) continue;
	if (isset($elt[3])) {
		$date= substr($elt[3],1, 11);
		if (!isset($data[$date]['cpt'])) $data[$date]['cpt']=1;
		else $data[$date]['cpt']++;
		
		$urls=explode("?", $elt[6]);
		$url=$urls[0];
		if (!isset($data[$date][$url])) $data[$date][$url]['cpt']=1;
		else $data[$date][$url]['cpt']++;
	}
    }
    fclose($fd);
}

foreach ($data as $d => $f) {
	foreach ($data[$d] as $url => $content) {
		if ($url=='cpt') continue;
		print "$d;$url;".$cpt=$data[$d][$url]['cpt']."\n";

	}
}
print_r($data);
?>
